#include "Vector2D.h"

void Vector2D::normalize() {
	float mag = getMagnitude();
	x = x / mag;
	y = y / mag;
}

Vector2D Vector2D::getNormalized() {
	float mag = getMagnitude();
	return Vector2D( (x / mag), (y / mag) );
}

float Vector2D::getMagnitude() {
	return sqrt( (x * x) + (y * y) );
}

Vector2D Vector2D::operator+ (Vector2D param) {
	return Vector2D( (x + param.x), (y + param.y) );
}

Vector2D Vector2D::operator- (Vector2D param) {
	return Vector2D( (x - param.x), (y - param.y) );
}

Vector2D Vector2D::operator+= (Vector2D param) {
	x = x + param.x;
	y = y + param.y;
	return *this;
}

Vector2D Vector2D::operator-= (Vector2D param) {
	x = x - param.x;
	y = y - param.y;
	return *this;
}

std::ostream& operator<< (std::ostream& out, const Vector2D param) {
	out << "(" << param.x << ", " << param.y << ")";
	return out;
}